<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="renderer" content="webkit">
	    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
		<title>客户列表</title>
		<link rel="stylesheet" href="__PUBLIC__/frame/layui/css/layui.css">
			<!--<link rel="stylesheet" href="http://cdn.datatables.net/1.10.13/css/jquery.dataTables.min.css">-->
		<link rel="stylesheet" href="__PUBLIC__/frame/static/css/style.css">
	</head>
	<body>
		  <a href="<?php echo U('Customer/add',array('type'=>'Sale'));?>"><button class="layui-btn" style="margin-top: 10px;"><i class="layui-icon">&#xe654;</i>添加客户</button></a>
    	<a class="layui-btn btn-add btn-default" id="btn-refresh" style="margin-top: 10px;"><i class="layui-icon">&#x1002;</i></a>
      <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
        <legend>搜索</legend>
      </fieldset>
      <form class="layui-form" id="search_form" action="__SELF__" method="post">
      <div class="layui-form-item">           
        <div class="layui-inline">
          <label class="layui-form-label">部门</label>
          <div class="layui-input-inline">
            <select name="part_id" lay-filter="part_id" lay-verify="required" lay-search="">
              <option value="">直接选择或搜索选择</option>
<?php foreach ($list['part'] as $k => $v):
if ($list['search']['part_id']==$v['id'])
  $select = 'selected = "selected"';
else
  $select = '';
?>
              <option {$select} value="{$v['id']}">{$v['name']}</option>
<?php endforeach;?>
            </select>
          </div>
        </div>
        <div class="layui-inline">
          <label class="layui-form-label">业务员</label>
          <div class="layui-input-inline">
            <select name="sale_worker" lay-filter="sale_worker" lay-verify="required" lay-search="">
              <option value="">直接选择或搜索选择</option>
<?php foreach ($list['sale_worker'] as $k => $v):
if ($list['search']['sale_worker']==$v['id'])
  $select = 'selected = "selected"';
else
  $select = '';
?>
              <option {$select} value="{$v['id']}">{$v['nickname']}</option>
<?php endforeach;?>
            </select>
          </div>
        </div>
        <div class="layui-inline">
          <label class="layui-form-label">客户</label>
          <div class="layui-input-inline">
            <select name="cus_id" lay-filter="cus_id" lay-verify="required" lay-search="">
              <option value="">直接选择或搜索选择</option>
<?php foreach ($list['customer'] as $k => $v):
if ($list['search']['cus_id']==$v['id'])
  $select = 'selected = "selected"';
else
  $select = '';
?>
              <option {$select} value="{$v['id']}">{$v['cusname']}</option>
<?php endforeach;?>
            </select>
          </div>
        </div>
        <div class="layui-inline">
          <label class="layui-form-label">查询时间段</label>
          <div class="layui-input-inline" style="width: 100px;">
            <input type="text" name="time_start" lay-verify="required" id="date2"  autocomplete="off" class="layui-input" value="{$list['search'][time_start]}">
          </div>
          <div class="layui-form-mid">-</div>
          <div class="layui-input-inline" style="width: 100px;">
            <input type="text" name="time_end" lay-verify="required" id="date3"  autocomplete="off" class="layui-input" value="{$list['search'][time_end]}">
          </div>
        </div> 
        <div class="layui-inline">
        <div class="layui-input-inline">
         <button type="submit" class="layui-btn layui-btn-primary layui-btn-radius">搜 索</button>
       </div>
       </div>
        <div class="layui-inline" style="width: 500px;">
          <label class="layui-form-label">业绩：</label>
          <if condition="$list['yeji']['code'] eq 1 ">
            <span style="padding:5px 0;width:100px;line-height:28px;"><font id="yeji" color="red" size="5">{$list['yeji']['msg']}</font> &nbsp;&nbsp;元</span>
            <else /> 
            <span style="padding:5px 0;width:100px;line-height:28px;">{$list['yeji']['msg']}</span>
          </if>          
        </div>
      </div>
      </form>
      <fieldset class="layui-elem-field layui-field-title">
        <legend>客户列表</legend>
      </fieldset>
    	<table class="layui-table" border="" cellspacing="" cellpadding="" width="100%">
    		<thead>
    			<tr>
    				<td width="5%">序号</td>
    				<td width="10%">客户姓名</td>
    				<td width="5%">性别</td>
            <td width="10%">联系电话</td>
    				<td width="10%">订单总额(元)</td>
    				<td width="8%">客服专员</td>
    				<td width="8%">业务员</td>
            <td width="8%">业务主任</td>
            <td width="8%">业务经理</td>
            <td width="10">进度</td> 				
    				<td width="5%">详情</td>
    				<td width="15%">操作</td>
    			</tr>
    		</thead>
            <tbody>
<if condition="$list['count'] gt 0 ">
<?php foreach ($list['list'] as $k => $v):?>
            	<tr class="<?php echo $v['status']==1?'defriend':'';?>">
            		<td><?php echo $v['id'];?></td>
            		<td><?php echo $v['cusname'];?></td>
            		<td><?php echo $v['sex'];?></td>
                <td cid="<?php echo $v['id'];?>"><?php echo $v['tel'];?></td>
            		<td><?php echo $v['allMoney'];?></td>
            		<td><?php echo $v['server_worker_name'];?></td>
            		<td><?php echo $v['sale_worker_name'];?></td>
                <td><?php echo $v['sale_head_name'];?></td>
                <td><?php echo $v['sale_manager_name'];?></td>
                <td><?php echo $v['is_checked']==0?'未审核':($v['is_checked']==1?'一审未通过':($v['is_checked']==2?'二审未通过':($v['is_checked']==6?'一通':'二通')));?></td>            		
            		<td><a  class="layui-btn layui-btn-mini more" cid="<?php echo $v['id']?>">更多信息</a></td>
            		<td>            		 
      					  <a id='chat' class="layui-btn layui-btn-mini" cus_id="{$v['id']}" lay-event="edit">沟通记录</a>
                  <a id='stock' cus_id="{$v['id']}" class="layui-btn layui-btn-mini" lay-event="edit">股票记录</a>
            		</td>
            	</tr>
<?php endforeach;?>
<?php if(preg_match('/\d/', $list['page'])): ?>  
        <tr><td align="right" nowrap="true" colspan="99" height="30" class="page"><?php echo $list['page']; ?></td></tr> 
<?php endif; ?>  
            </tbody>
<else /><tbody><tr><td align="center" nowrap="true" colspan="99" style="font-size:24px;padding:30px 0;">你还无客户，继续努力吧！</td></tr></tbody>
</if>
    	</table>
	</body>
</html>
<script type="text/javascript" src="__PUBLIC__/hawk/js/jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/frame/layui/layui.js"></script>
    <script>
              // 刷新
        $('#btn-refresh').on('click', function () {
            document.getElementById("search_form").reset();
            location.reload();
        });
    layui.use(['layer','layedit', 'laydate'], function(){
          var layer = layui.layer
          ,layedit = layui.layedit
          ,laydate = layui.laydate;

          //日期选择
          laydate.render({
            elem: '#date2'
          });
          laydate.render({
            elem: '#date3'
          });   
        //查看客户详情
        $(document).on('click','.more',function(){
            var cid=$(this).attr('cid');
            layer.open({
              type: 2,
              title:'客户详细信息',
              area: ['100%', '100%'],
              fixed: false, //不固定
              maxmin: true,
              content: '/index.php/Hawk/Customer/moreInfo/id/'+cid
            });
        });href="<?php echo U('Sale/chat?id='.$v['id'].'&p='.I('get.p')); ?>"
        //沟通记录
        $(document).on('click','#chat',function(){
            var cid=$(this).attr('cus_id');
            layer.open({
              type: 2,
              title:'客户沟通记录',
              area: ['100%', '100%'],
              fixed: false, //不固定
              maxmin: true,
              content: '/index.php/Hawk/Sale/chat/id/'+cid
            });
        });
        //股票记录
        $(document).on('click','#stock',function(){
            var cid=$(this).attr('cus_id');
            layer.open({
              type: 2,
              title:'客户沟通记录',
              area: ['100%', '100%'],
              fixed: false, //不固定
              maxmin: true,
              content: '/index.php/Hawk/Sale/stock/id/'+cid
            });
        });
        //获取业绩
        $(document).on('click','#search',function(){
          var start_time = $('input[name=time_start]').val();
          var end_time = $('input[name=time_end]').val();
          $.post('/index.php/Hawk/Sale/ajaxyeji',{'start_time':start_time,'end_time':end_time},function(data){
            var obj=eval('(' + data + ')');
            if(obj.code==1){
              $('#yeji').text(obj.msg);
            }else if(obj.code==1000){
              layer.msg(obj.msg);
            }
          });
        });
    });
    
    </script>
